package com.springboot.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class MyConfig {

    @Bean
    @Scope("singleton")
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean frb = new FilterRegistrationBean();
        MyFilter mf = new MyFilter();
        frb.setFilter(mf);
        List<String> list = new ArrayList<>();
        //配置过滤规则
        list.add("/hc/*");
        frb.setUrlPatterns(list);
        return frb;
    }
}
